﻿@model IEnumerable<MVC_Store.Models.ViewModels.Pages.PageVM>

@{
    ViewBag.Title = "Pages";
}

<h2>Pages</h2>

@if (TempData["SM"] != null)
{
    <div class="alert alert-success">
        @TempData["SM"]
    </div>
}

<p>
    @Html.ActionLink("Create New Page", "AddPage", "", new { @class = "btn btn-success" })
</p>

<table class="table sorting" id="pages">
    <tr class="home">
        <th>
            Title
        </th>
        <th>
            Slug
        </th>

        <th>
            Sidebar
        </th>
        <th></th>
    </tr>

    @foreach (var item in Model)
    {
        <tr id="id_@item.Id" class="@item.Slug">
            <td>
                @if (item.Slug != "home")
                {
                    <span class="ui-icon ui-icon-arrowthick-2-n-s"></span>
                }
                @Html.DisplayFor(modelItem => item.Title)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Slug)
            </td>

            <td>
                @Html.DisplayFor(modelItem => item.HasSidebar)
            </td>
            <td>
                @Html.ActionLink("Edit", "EditPage", new { id = item.Id }) |
                @Html.ActionLink("Details", "PageDetails", new { id = item.Id })

                @if (item.Slug != "home")
                {
                    string slash = "| ";
                    @slash;
                    @Html.ActionLink("Delete", "DeletePage", new { id = item.Id }, new { @class = "delete" })
                }

            </td>
        </tr>
    }

</table>
@section Scripts
{
    <script src="~/Content/ShopJS/PagesIndexViewJS.js"></script>
}
